<template>
	<a-select
		v-model:value="select"
		:options="options"
		:field-names="{ label: 'typeValue', value: 'id' }"
		allowClear
		@change="selectChange"
	/>
</template>
<script setup>
	import industryApi from '@/api/biz/crm/industryApi'
	const props = defineProps({
		value: {
			type: Number
		},
		name: {
			type: String
		}
	})
	onBeforeMount(() => {
		if (props.value) {
			select.value = Number(props.value)
		}
		if (props.name) {
			industryName.value = props.name
		}
	})
	/**
	 * 获取地区数据级联选择
	 */
	const select = ref(null)
	const options = ref([])
	const industryName = ref('')
	industryApi.getIndustry().then((res) => {
		options.value = res
	})
	const selectChange = (value, option) => {
		industryName.value = option ? option.typeValue : null
	}
	defineExpose({
		select,
		industryName
	})
</script>
